<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Prospect_Update_List extends Page
{
       public $Image1 = null;
       public $JSEdit = null;
       public $btnSearch = null;
       public $edSearch = null;
       public $Image4 = null;
       public $imgBack = null;
       public $hfCompanyId = null;
       public $add = null;
       public $JTSiteTheme1 = null;
       public $JTProspectUpdate = null;
       function edSearchJSClick($sender, $params)
       {

       ?>
       document.getElementById('edSearch').value = '';

       <?php

       }
       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       document.images['imgBack'].src="image/btn_back2.png"

       <?php

       }

       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       document.images['imgBack'].src="image/btn_back.png"

       <?php

       }
       function imgBackJSClick($sender, $params)
       {

       ?>
       comp_id = document.getElementById('hfCompanyId').value;
       document.location.href = "prospect_list.php";

       <?php

       }

       function Prospect_Update_ListJSLoad($sender, $params)
       {

       ?>
       document.getElementById('JTProspectUpdate_colitem_hdr_0').width = '100px';
       document.getElementById('JTProspectUpdate_colitem_hdr_1').width = '350px';
       document.getElementById('JTProspectUpdate_colitem_hdr_2').width = '350px';

       document.getElementById('JTProspectUpdate_colitem_body_0').width = '100px';
       document.getElementById('JTProspectUpdate_colitem_body_1').width = '350px';
       document.getElementById('JTProspectUpdate_colitem_body_2').width = '350px';
       <?php

       }

       function Prospect_Update_ListCreate($sender, $params)
       {
        $company_id = $_GET['company_id'];
        $this->hfCompanyId->setValue($company_id);
       }

       function JTProspectUpdateShow($sender, $params)
       {
       $query_update = "SELECT * FROM prospects_updates_tbl WHERE
       company_id='".$this->hfCompanyId->getValue()."' AND
       (
       date LIKE '%".$this->edSearch->Text."%' OR
       updates LIKE '%".$this->edSearch->Text."%' OR
       jti_remark LIKE '%".$this->edSearch->Text."%'
       )
       ORDER BY date DESC,autoid DESC
       ";
       $result_update = mysql_query($query_update) or die("SELECT UPDATES ".mysql_error());
       $grid_arr = array();
       while($row_update = mysql_fetch_array($result_update))
       {
        $date = $row_update['date'];
        $edit_date = "<span title='Edit' style='text-decoration:underline;color:blue;cursor:pointer' onClick=edit('".$row_update['autoid']."')>".$date."</span>";
        $column1 = $edit_date;
        $column2 = $row_update['updates'];
        $column3 = $row_update['jti_remark'];
        $grid_arr[] = array(
        'Date'=>$column1,
        'Update'=>$column2,
        'Remarks'=>$column3
        );
       }
       $this->JTProspectUpdate->setCellData($grid_arr);
       }


       function addJSClick($sender, $params)
       {

       ?>
       company_id = document.getElementById('hfCompanyId').value;
       var win_height = 380;
       var win_width = 500;
       var height = window.outerHeight;
       var width = window.outerWidth;
       var top = Math.round((height-win_height)/2);
       var left = Math.round((width-win_width)/2);
       window.open("prospect_update_create.php?company_id="+company_id,"add_update",'location=no,height='+win_height+',width='+win_width+',top='+top+',left='+left);

       <?php

       }
       function addJSMouseOut($sender, $params)
       {

       ?>
       document.images['add'].src="image/add_new.png";

       <?php

       }

       function addJSMouseOver($sender, $params)
       {

       ?>
       document.images['add'].src="image/add_new_blue.png";
       <?php

       }

}

global $application;

global $Prospect_Update_List;

//Creates the form
$Prospect_Update_List=new Prospect_Update_List($application);

//Read from resource file
$Prospect_Update_List->loadResource(__FILE__);

//Shows the form
$Prospect_Update_List->show();

?>